package com.bnq.logc.work

import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.bnq.logc.Logc
import com.bnq.logc.upload.UploadFileManager
import com.bnq.logc.utils.DateUtil

class LogcUploadWorker(context: Context,workerParameters: WorkerParameters):Worker(context,workerParameters) {

    override fun doWork(): Result {
        val key = System.currentTimeMillis().toString()
        Logc.i("UploadWorker",">>>> LogcUploadWorker -> doWork start key:$key, ${DateUtil.currentDateTimeString()}")
        UploadFileManager.checkAndUploadFileLast7{checkUploadResult ->
            Logc.i("UploadWorker","<<<< LogcUploadWorker -> doWork end key:$key, ${DateUtil.currentDateTimeString()}, uploadResult:${checkUploadResult.getUploadSuccessRateString()}, e: ${checkUploadResult.e},  isUploadLog: ${checkUploadResult.isUploadLog}, uploadError: ${checkUploadResult.getSimpleUploadErrorInfoString()}")
        }
        return Result.success()
    }
}